extends "res://ui/msgBaseX/msgBaseX.gd"

onready  var txt = $Panel / RichTextLabel
var base = globalData.infoDs["g_azurlaneBase"]
func _ready():
	pass

func init(win = true):
	var sbs = ""
	if win:
		$Panel / Label.text = "通关！"
	else :
		$Panel / Label.text = "失败！"
		if sys.main.player.hp > 0:
			sbs = tr("队伍全灭！")
		else :sbs = tr("玩家生命值为0！！")

	var diamonds = 0
	if win:
		diamonds = jinJieData.nowLv + 2
	elif sys.main.getStep() > 50:
		diamonds = 2

	txt.bbcode_text = sbs
	
	txt.bbcode_text += """
	{jinjieLvT}：{jinJieLv}
	[color=#b87850]{lvT}： {lv}
	
	{sgT}：{diamonds}[/color]
	"""
	var lv = sys.main.guankaMsg.lvStep - 2
	
	sys.main.isEnd = true
	
	var dic = {
		lv = lv, 
		jinJieLv = jinJieData.nowLv, 
		jinjieLvT = tr("难度等级"), 
		lvT = tr("你占领层数"), 
		sgT = tr("获得至纯晶钻"), 
		diamonds = diamonds
	}

	

	base.plusSetting("diamonds", diamonds)
	
	txt.bbcode_text = txt.bbcode_text.format(dic)

	if win:
		if jinJieData.upLv():
			sys.newBaseMsg("信息", "解锁新的进阶等级成功！")
			
		if sys.isDemo:
			sys.newBaseMsg("信息", "试玩版只能到达这里！")
	popup()

func _on_Button_pressed():
	queue_free()

func _on_Button2_pressed():
	queue_free()
	if sys.main != null:
		sys.main.exit()
